package cn.cubix.flow.controller.dto.workflow;

import lombok.Data;
import lombok.experimental.Accessors;
import org.flowable.engine.repository.ProcessDefinition;

@Data
@Accessors(chain = true)
public class DefinitionDto {
    protected String id;
    protected String category;
    protected String name;
    protected String key;
    protected String description;
    protected Integer version;
    protected String resourceName;
    protected String deploymentId;
    protected String diagramResourceName;
    protected Boolean hasStartFormKey;
    protected Boolean hasGraphicalNotation;
    protected Boolean suspended;
    protected String tenantId;
    protected String derivedFrom;
    protected String derivedFromRoot;
    protected Integer derivedVersion;
    protected String engineVersion;

    public static DefinitionDto from(ProcessDefinition processDefinition){
        return new DefinitionDto()
                .setId(processDefinition.getId())
                .setCategory(processDefinition.getCategory())
                .setName(processDefinition.getName())
                .setKey(processDefinition.getKey())
                .setDescription(processDefinition.getDescription())
                .setVersion(processDefinition.getVersion())
                .setResourceName(processDefinition.getResourceName())
                .setDeploymentId(processDefinition.getDeploymentId())
                .setDiagramResourceName(processDefinition.getDiagramResourceName())
                .setHasStartFormKey(processDefinition.hasStartFormKey())
                .setHasGraphicalNotation(processDefinition.hasGraphicalNotation())
                .setSuspended(processDefinition.isSuspended())
                .setTenantId(processDefinition.getTenantId())
                .setDerivedFrom(processDefinition.getDerivedFrom())
                .setDerivedFromRoot(processDefinition.getDerivedFromRoot())
                .setDerivedVersion(processDefinition.getDerivedVersion())
                .setEngineVersion(processDefinition.getEngineVersion());
    }
}
